//index.js
const app = getApp()
const DB = wx.cloud.database();
let len = "";
let len2 = "";
Page({
  data: {
    type:wx.getStorageSync('user').xinwentype,
    // top标签显示（默认不显示）
    backTopValue:false ,
    orderItem: [],
    orderItem2: [],
    banner: [{
        img: '../../images/aaa.jpg'
      },
      {
        img: '../../images/bbb.png'
      },
    ],
  },
  onLoad: function () {
    this.setData({
      type:wx.getStorageSync('user').xinwentype
    })
  },
  onShow() {
    len2 = this.data.orderItem2.length
    DB.collection('news').where({

    }).skip(len).orderBy('time_order', 'desc').get().then(res => {
      let oldData = this.data.orderItem2;
      console.log("b", res)
      wx.hideLoading();
      this.setData({
        orderItem2: res.data
      })
      console.log("this", this.data.orderItem2)
    })
  },
  goDetail(e) {
    wx.navigateTo({
      url: '../newsdetail/index?id=' + e.currentTarget.dataset.id,
    })
  },


  morehuodong() {
    wx.navigateTo({
      url: '../morenews/morenews',
    })
  },

  goDetail2(e) {
    wx.navigateTo({
      url: '../shetuanguanlidetail/shetuanguanlidetail?id=' + e.currentTarget.dataset.id,
    })
  },
  sousuo() {
    console.log('e')
    wx.navigateTo({
      url: '../morenews/morenews',
    })
  },
    // 监听滚动条坐标
    onPageScroll: function (e) {
      var scrollTop = e.scrollTop
      var backTopValue = scrollTop > 500 ? true : false
      this.setData({
        backTopValue: backTopValue
      })
    },
  
    // 滚动到顶部
    backTop:function(){
      // 控制滚动
      wx.pageScrollTo({
        scrollTop: 0
      })
    },
})